namespace rateITcd.Migrations
{
    using Microsoft.AspNet.Identity;
    using Microsoft.AspNet.Identity.EntityFramework;
    using rateITcd.Models;
    using System;
    using System.Collections.Generic;
    using System.Data.Entity;
    using System.Data.Entity.Migrations;
    using System.Linq;

    internal sealed class Configuration : DbMigrationsConfiguration<rateITcd.Models.RateItDB>
    {
        public Configuration()
        {
            AutomaticMigrationsEnabled = true;
        }

        protected override void Seed(rateITcd.Models.RateItDB context)
        {

            context.Restaurants.AddOrUpdate(r => r.Name,
               new Restaurant
               {
                   Name = "Tasty Bowl",
                   AdressStreet = "Fruitmarkt",
                   AdressNumber = "34",
                   AdressCity = "Hasselt",
                   AdressZip = "3500",
                   Longtitude = "5.339370",
                   Latitude = "50.929903",
                   Dishes = new List<RestaurantDish> { 
                                   new RestaurantDish { Name = "Red Cury", Price = 9.30}
                            }
               });
            //var userManager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ApplicationDbContext()));
            var roleManager = new RoleManager<IdentityRole>(new RoleStore<IdentityRole>());

            //var newUser = new ApplicationUser()
            //{
            //    Email = "admin@rateit.be",
            //    UserName = "admin"
            //};

            //userManager.CreateAsync(newUser, "P@ssw0rd-");
            if (!roleManager.RoleExists("User"))
                roleManager.Create(new IdentityRole("User"));
            if (!roleManager.RoleExists("Admin"))
                roleManager.Create(new IdentityRole("Admin"));
            //userManager.AddToRole(newUser.Id, "Admin");

        }

    }
}

